package com.swingson.interpreter.ast;

import com.swingson.interpreter.ast.base.BaseAst;

/**
 * @author sad
 */
public class PercentAst extends BaseAst {

    private final BaseAst percentCountAst;
    private final BaseAst operandAst;

    public PercentAst(BaseAst percentCountAst, BaseAst operandAst) {
        this.percentCountAst = percentCountAst;
        this.operandAst = operandAst;
    }

    @Override
    public float process() {
        float operandValue = operandAst.process();
        float percent = percentCountAst.process();
        return operandValue / 100.0f * percent;
    }

}
